''' 几何形状的绘制 '''
import cv2 as cv
import numpy as np

img = cv.imread('../resources/miku.jpg')

# img = np.zeros((512, 512, 3), dtype=np.uint8)
# 绘制矩形
# thickness: -1表示填充, >0表示不填充
cv.rectangle(img, (100, 100), (300, 300), (0, 255, 255), 2) # img, point1, point2, color, thickness, lineType, shifts(坐标点的小数点的位数)
# 绘制圆
cv.circle(img, (256, 256), 100, (0, 0, 255), 2) # img, center, radius, color, thickness, lineType, shifts
# 绘制椭圆
cv.ellipse(img, (256, 256), (100, 50), 0, 0, 360, (0, 255, 0), 2) # img, center, axes, angle, startAngle, endAngle, color, thickness, lineType, shifts
# 绘制直线
cv.line(img, (0, 0), (256, 256), (255, 0, 0), 2)

# 但没有很好的方法进行擦除
# 可以使用np.copy来实现类似效果

# 绘制多边形
pts = np.array([[10, 5], [20, 30], [70, 20], [50, 10]], np.int32)
cv.polylines(img, [pts], True, (0, 255, 255), 2)
# pts = pts.reshape((-1, 1, 2))
# cv.fillPoly(b1, [pts], (0, 0, 255))

# 绘制文字
cv.putText(img, 'Hello World', (10, 500), cv.FONT_HERSHEY_SIMPLEX, 4, (0, 0, 255), 2)

cv.imshow('b1', img)
cv.waitKey(0)
cv.destroyAllWindows()
